const db = require("../../config/db");

module.exports = {
    //获取新闻搜索列表
    getSearchList({ searchVal }) {
        return new Promise((resolve, reject) => {
            let get_searchlist_sql = `select * from db_news where title like "%${searchVal}%" and keyword like "%${searchVal}%" limit 0,20`;
            db.query(get_searchlist_sql, (err, rows) => {
                if (err) {
                    reject(err);
                } else {
                    resolve(rows);
                }
            });
        });
    },

    //获取新闻主题列表
    getCategoryList({ newsCategory }) {
        return new Promise((resolve, reject) => {
            let get_category_sql = `select * from db_news where category="${newsCategory}" limit 50`;
            db.query(get_category_sql, (err, rows) => {
                if (err) {
                    reject(err);
                } else {
                    resolve(rows);
                }
            });
        });
    },
};
